//
//  SLStartAuthenticationComponent.m
//  SulitLoanDemo
//
//  Created by 虞嘉伟 on 2025/2/20.
//  
  

#import "SLStartAuthenticationComponent.h"
#import <YYKit.h>
#import <Masonry.h>


@implementation SLStartAuthenticationComponent

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
        [self addSubview:self.bgView];
        [self addSubview:self.startAuthentication];
        [self addSubview:self.decorate];
        [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self);
            make.top.equalTo(self).offset(29);
            make.bottom.equalTo(self);
        }];
        [self.startAuthentication mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(19);
            make.bottom.equalTo(self).inset(24);
            make.height.mas_equalTo(45);
            make.width.mas_equalTo(_startAuthentication.intrinsicContentSize.width+20*2);
        }];
        [self.decorate mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).inset(12);
            make.top.bottom.equalTo(self);
            make.width.mas_equalTo(132);
        }];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.startAuthentication.layer.cornerRadius = CGRectGetHeight(self.startAuthentication.bounds)*0.5;
    [self.bgView roundTopCornerRadius:20];
}

- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [UIView new];
        _bgView.backgroundColor = UIColorHex(#1B1B1B);
    }
    return _bgView;
}
- (SLMoreButton *)startAuthentication {
    if (!_startAuthentication) {
        _startAuthentication = [SLMoreButton new];
        _startAuthentication.titleLabel.text = @"Start Authentication";
        _startAuthentication.titleLabel.textColor = UIColorHex(#1B1B1B);
        _startAuthentication.imageView.image = [UIImage imageNamed:@"btn_more_white"];
        _startAuthentication.backgroundColor = UIColorHex(#FDC5E0);
        _startAuthentication.titleLabel.font = aspectDefaultFont(16);
    }
    return _startAuthentication;
}
- (UIImageView *)decorate {
    if (!_decorate) {
        _decorate = [UIImageView new];
        _decorate.contentMode = UIViewContentModeScaleAspectFit;
        _decorate.image = [UIImage imageNamed:@"icon_start_auth"];
    }
    return _decorate;
}

@end
